package com.telenav;

import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;

public class LinkBlock {

	public int x;
	public int y;
	public boolean isLinked = false;
	public Rectangle rect = new Rectangle();
	public Point centPoint = new Point();
	public ArrayList<RGB> calPoints = new ArrayList<RGB>();

	public LinkBlock(Rectangle rect) {
		this.rect = rect;
		this.centPoint = new Point(rect.x + rect.width / 2, rect.y + rect.height / 2);
	}

	public int sub(LinkBlock linkBlock) {
		int sum = 0;
		for (int i = 0; i < calPoints.size(); i++) {
			sum += Math.abs(calPoints.get(i).sub(linkBlock.calPoints.get(i)));
		}
		if (calPoints.size() == 0) {
			return 0;
		}
		return sum / calPoints.size();
	}

	public String toString() {
		return x + "," + y;
	}
}
